﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DuJianliang.ApplicationPlatform.Proj5715.Process
{
    public partial class ProcessExchangePart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["DispatchMissileProcessID"] = Request.QueryString["DispatchMissileProcessID"].Trim();

                BindGrid();
            }
        }

        private void BindGrid()
        {
            var dal = new ProcessDal();
            List<ExchangePartOB> list = dal.GetExchangePartObList(ViewState["DispatchMissileProcessID"].ToString());

            rpt.DataSource = list;
            rpt.DataBind(); 
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            //Response.Redirect("ProcessExchangePartEdit.aspx?DispatchMissileProcessID=" + ViewState["DispatchMissileProcessID"].ToString());
            Response.Redirect("ExchangeAuditSelect.aspx?DispatchMissileProcessID=" + ViewState["DispatchMissileProcessID"].ToString());
        }

        protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            { 
                case "Modify":
                    
                    Response.Redirect("ProcessExchangePartEdit.aspx?DispatchMissileProcessID=" + ViewState["DispatchMissileProcessID"].ToString()+"&ID="+e.CommandArgument.ToString());

                    break;
                case "Del":
                    var dal = new ProcessDal();
                    dal.ExchangePartOB_Delete(e.CommandArgument.ToString());

                    BindGrid();
                    break;
            }
        }
    }
}